{extend name="index/iframe" /}

{block name="content"}
<form class="layui-form layui-form-my" action="">
    <input type="hidden" name="id" value="{$Think.get.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">添加类型</label>
        <div class="layui-input-block">
            <select disabled lay-filter="add_type" id="add_type" lay-verify="required">
                <option value="1" {$find.add_type==1 ? 'selected' : ''}>礼包文件</option>
                <option value="2" {$find.add_type==2 ? 'selected' : ''}>单个礼包码</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼包名称</label>
        <div class="layui-input-block">
            <input type="text" value="{$find.name}" name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">选择游戏</label>
        <div class="layui-input-block">
            {MyTag:game type='manage' id="$find['game_id']" disabled="1" /}
        </div>
    </div>
    {if condition="$find.add_type eq 1"}
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">可领数量</label>
        <div class="layui-input-block">
            <input type="text" value="{$find.give_num}" name="give_num" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    {/if}
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">使用方法</label>
        <div class="layui-input-block">
            <textarea name="explain" placeholder="请输入使用方法" class="layui-textarea">{$find.explain}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">礼包内容</label>
        <div class="layui-input-block">
            <textarea name="content" placeholder="请输入礼包内容" class="layui-textarea">{$find.content}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn my-btn" lay-submit="" lay-filter="submitBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="css"}{/block}

{block name="js"}
<script>
layui.use(['form', 'layedit'], function(){
    var form = layui.form
        ,$ = layui.$
        ,layer = layui.layer;

    //提交
    form.on('submit(submitBtn)', function(data){
        var load = layer.load();
        $.post('{:url("ChannelBag/edit")}',data.field, function(json){
            layer.close(load);
            json.code==0 ? layer.msg(json.msg, {icon: 1, time: 1000}) : layer.msg(json.msg, {icon: 0, time: 1000});
        }, 'JSON').error(function(){
            layer.close(load);
            layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
        });
        return false;
    });
});
</script>
{/block}